package web.dropwizard.configuration;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.hibernate.validator.constraints.NotEmpty;
import util.mongodb.BasicMongoDBDataSource;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

/**
 * @author Gregory Boissinot
 */
public class MongoConfig {

    @JsonProperty(required = true)
    @NotEmpty
    private String mongoHost;

    @JsonProperty(required = true)
    @Min(1)
    @Max(65535)
    private int mongoPort;

    @JsonProperty(required = true)
    @NotEmpty
    private String mongoDbName;

    public String getMongoHost() {
        return mongoHost;
    }

    public void setMongoHost(String mongoHost) {
        this.mongoHost = mongoHost;
    }

    public int getMongoPort() {
        return mongoPort;
    }

    public void setMongoPort(int mongoPort) {
        this.mongoPort = mongoPort;
    }

    public String getMongoDbName() {
        return mongoDbName;
    }

    public void setMongoDbName(String mongoDbName) {
        this.mongoDbName = mongoDbName;
    }

    public BasicMongoDBDataSource getMongoDBDataSource() {
        return new BasicMongoDBDataSource(this.getMongoHost(), this.getMongoPort(), this.getMongoDbName());
    }
}

